<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"zzcz.cc","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="点击看详情">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS常用宏定义">
<meta property="og:url" content="http://zzcz.cc/d1cbe53b.html">
<meta property="og:site_name" content="茁壮成长">
<meta property="og:description" content="点击看详情">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-02-24T12:53:22.000Z">
<meta property="article:modified_time" content="2020-02-25T13:02:48.000Z">
<meta property="article:author" content="YAND">
<meta property="article:tag" content="iOS">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://zzcz.cc/d1cbe53b.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>iOS常用宏定义 | 茁壮成长</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">茁壮成长</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">人生在世 难得糊涂</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://zzcz.cc/d1cbe53b.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="YAND">
      <meta itemprop="description" content="成长历程 IT笔记 黑苹果 杂谈 建站 服务器 VPS">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="茁壮成长">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          iOS常用宏定义
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-02-24 20:53:22" itemprop="dateCreated datePublished" datetime="2020-02-24T20:53:22+08:00">2020-02-24</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-02-25 21:02:48" itemprop="dateModified" datetime="2020-02-25T21:02:48+08:00">2020-02-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/iOS/" itemprop="url" rel="index"><span itemprop="name">iOS</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <center>点击看详情</center>

<span id="more"></span>

<p>宏定义可以很方便开发和调试，我们也要对其进行归类，提高代码可读性和规范性。</p>
<p>宏定义在很多方面都会使用，例如定义高度、判断iOS系统、工具类，还有诸如文件路径、服务端api接口文档。为了对宏能够快速定位和了解其功能，我们最好在定义的时候将其放入特定的头文件中，下面我抛砖引玉，对一些常用的宏进行分类、分文件定义，希望对大家有所帮助。</p>
<p>1.定义尺寸类的宏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">DimensMacros.h</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;状态栏高度</span><br><span class="line">#define STATUS_BAR_HEIGHT 20</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;NavBar高度</span><br><span class="line">#define NAVIGATION_BAR_HEIGHT 44</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;状态栏 ＋ 导航栏 高度</span><br><span class="line">#define STATUS_AND_NAVIGATION_HEIGHT ((STATUS_BAR_HEIGHT) + (NAVIGATION_BAR_HEIGHT))</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;屏幕 rect</span><br><span class="line">#define SCREEN_RECT ([UIScreen mainScreen].bounds)</span><br><span class="line">#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)</span><br><span class="line">#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)</span><br><span class="line">#define CONTENT_HEIGHT (SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - STATUS_BAR_HEIGHT)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;屏幕分辨率</span><br><span class="line">#define SCREEN_RESOLUTION (SCREEN_WIDTH * SCREEN_HEIGHT * ([UIScreen mainScreen].scale))</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;广告栏高度</span><br><span class="line">#define BANNER_HEIGHT 215</span><br><span class="line">#define STYLEPAGE_HEIGHT 21</span><br><span class="line">#define SMALLTV_HEIGHT 77</span><br><span class="line">#define SMALLTV_WIDTH 110</span><br><span class="line">#define FOLLOW_HEIGHT 220</span><br><span class="line">#define SUBCHANNEL_HEIGHT 62</span><br></pre></td></tr></table></figure>
<p>2.定义沙盒目录文件的宏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">PathMacros.h</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;文件目录</span><br><span class="line">#define kPathTemp NSTemporaryDirectory()</span><br><span class="line">#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]</span><br><span class="line">#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]</span><br><span class="line">#define kPathSearch [kPathDocument stringByAppendingPathComponent:@&quot;Search.plist&quot;]</span><br><span class="line">#define kPathMagazine [kPathDocument stringByAppendingPathComponent:@&quot;Magazine&quot;]</span><br><span class="line">#define kPathDownloadedMgzs [kPathMagazine stringByAppendingPathComponent:@&quot;DownloadedMgz.plist&quot;]</span><br><span class="line">#define kPathDownloadURLs [kPathMagazine stringByAppendingPathComponent:@&quot;DownloadURLs.plist&quot;]</span><br><span class="line">#define kPathOperation [kPathMagazine stringByAppendingPathComponent:@&quot;Operation.plist&quot;]</span><br><span class="line">#define kPathSplashScreen [kPathCache stringByAppendingPathComponent:@&quot;splashScreen&quot;]</span><br></pre></td></tr></table></figure>
<p>3.工具类的宏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line">UtilsMacros.h</span><br><span class="line">&#x2F;&#x2F;Log utils marco</span><br><span class="line"></span><br><span class="line">#define ALog(fmt, ...) NSLog((@&quot;%s [Line %d] &quot; fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);</span><br><span class="line">#ifdef DEBUG</span><br><span class="line">#define DLog(fmt, ...) NSLog((@&quot;%s [Line %d] &quot; fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);</span><br><span class="line">#else</span><br><span class="line">#define DLog(...)</span><br><span class="line">#endif</span><br><span class="line"></span><br><span class="line">#ifdef DEBUG</span><br><span class="line">#define ULog(...)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;#define ULog(fmt, ...)  &#123; UIAlertView *alert &#x3D; [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@&quot;%s\n [Line %d] &quot;, __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__]  delegate:nil cancelButtonTitle:@&quot;Ok&quot; otherButtonTitles:nil]; [alert show]; &#125;</span><br><span class="line">#else</span><br><span class="line">#define ULog(...)</span><br><span class="line">#endif</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;System version utils</span><br><span class="line"></span><br><span class="line">#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] &#x3D;&#x3D; NSOrderedSame)</span><br><span class="line">#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] &#x3D;&#x3D; NSOrderedDescending)</span><br><span class="line">#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] !&#x3D; NSOrderedAscending)</span><br><span class="line">#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] &#x3D;&#x3D; NSOrderedAscending)</span><br><span class="line">#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] !&#x3D; NSOrderedDescending)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F; 获取RGB颜色</span><br><span class="line">#define RGBA(r,g,b,a) [UIColor colorWithRed:r&#x2F;255.0f green:g&#x2F;255.0f blue:b&#x2F;255.0f alpha:a]</span><br><span class="line">#define RGB(r,g,b) RGBA(r,g,b,1.0f)</span><br><span class="line"></span><br><span class="line">#define IsPortrait ([UIApplication sharedApplication].statusBarOrientation &#x3D;&#x3D; UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation &#x3D;&#x3D; UIInterfaceOrientationPortraitUpsideDown)</span><br><span class="line"></span><br><span class="line">#define IsNilOrNull(_ref)   (((_ref) &#x3D;&#x3D; nil) || ([(_ref) isEqual:[NSNull null]]))</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;角度转弧度</span><br><span class="line">#define DEGREES_TO_RADIANS(d) (d * M_PI &#x2F; 180)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;大于等于7.0的ios版本</span><br><span class="line">#define iOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@&quot;7.0&quot;)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;大于等于8.0的ios版本</span><br><span class="line">#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@&quot;8.0&quot;)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;iOS6时，导航VC中view的起始高度</span><br><span class="line">#define YH_HEIGHT (iOS7_OR_LATER ? 64:0)</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;获取系统时间戳</span><br><span class="line">#define getCurentTime [NSString stringWithFormat:@&quot;%ld&quot;, (long)[[NSDate date] timeIntervalSince1970]]</span><br></pre></td></tr></table></figure>
<p>4.通知Notification相关的宏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">NotificationMacros.h</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;系统Notification定义</span><br><span class="line">#define TNCancelFavoriteProductNotification     @&quot;TNCancelFavoriteProductNotification&quot;      &#x2F;&#x2F;取消收藏时</span><br><span class="line">#define TNMarkFavoriteProductNotification       @&quot;TNMarkFavoriteProductNotification&quot;        &#x2F;&#x2F;标记收藏时</span><br><span class="line"></span><br><span class="line">#define kNotficationDownloadProgressChanged     @&quot;kNotficationDownloadProgressChanged&quot;      &#x2F;&#x2F;下载进度变化</span><br><span class="line">#define kNotificationPauseDownload              @&quot;kNotificationPauseDownload&quot;               &#x2F;&#x2F;暂停下载</span><br><span class="line">#define kNotificationStartDownload              @&quot;kNotificationStartDownload&quot;               &#x2F;&#x2F;开始下载</span><br><span class="line"></span><br><span class="line">#define kNotificationDownloadSuccess            @&quot;kNotificationDownloadSuccess&quot;             &#x2F;&#x2F;下载成功</span><br><span class="line">#define kNotificationDownloadFailed             @&quot;kNotificationDownloadFailed&quot;              &#x2F;&#x2F;下载失败</span><br><span class="line">#define kNotificationDownloadNewMagazine        @&quot;kNotificationDownloadNewMagazine&quot;</span><br></pre></td></tr></table></figure>
<p>服务端API接口的宏</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">APIStringMacros.h</span><br><span class="line">&#x2F;&#x2F;接口名称相关</span><br><span class="line"></span><br><span class="line">#ifdef DEBUG</span><br><span class="line">&#x2F;&#x2F;Debug状态下的测试API</span><br><span class="line">#define API_BASE_URL_STRING     @&quot;http:&#x2F;&#x2F;boys.test.companydomain.com&#x2F;api&#x2F;&quot;</span><br><span class="line"></span><br><span class="line">#else</span><br><span class="line">&#x2F;&#x2F;Release状态下的线上API</span><br><span class="line">#define API_BASE_URL_STRING     @&quot;http:&#x2F;&#x2F;www.companydomain.com&#x2F;api&#x2F;&quot;</span><br><span class="line"></span><br><span class="line">#endif</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;接口</span><br><span class="line">#define GET_CONTENT_DETAIL      @&quot;channel&#x2F;getContentDetail&quot; &#x2F;&#x2F;获取内容详情(含上一个和下一个)</span><br><span class="line"></span><br><span class="line">#define GET_COMMENT_LIST        @&quot;comment&#x2F;getCommentList&quot;   &#x2F;&#x2F;获取评论列表</span><br><span class="line"></span><br><span class="line">#define COMMENT_LOGIN           @&quot;comment&#x2F;login&quot;            &#x2F;&#x2F;获取评论列表</span><br><span class="line"></span><br><span class="line">#define COMMENT_PUBLISH         @&quot;comment&#x2F;publish&quot;          &#x2F;&#x2F;发布评论</span><br><span class="line"></span><br><span class="line">#define COMMENT_DELETE          @&quot;comment&#x2F;delComment&quot;       &#x2F;&#x2F;删除评论</span><br><span class="line"></span><br><span class="line">#define LOGINOUT                @&quot;common&#x2F;logout&quot;            &#x2F;&#x2F;登出</span><br></pre></td></tr></table></figure>
<p>还有很多其他类型的宏，此处不一一列举</p>
<p>创建一个import所有宏相关的文件Macros.h</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">Macros.h</span><br><span class="line">#import &quot;UtilsMacros.h&quot;</span><br><span class="line">#import &quot;APIStringMacros.h&quot;</span><br><span class="line">#import &quot;DimensMacros.h&quot;</span><br><span class="line">#import &quot;NotificationMacros.h&quot;</span><br><span class="line">#import &quot;SharePlatformMacros.h&quot;</span><br><span class="line">#import &quot;StringMacros.h&quot;</span><br><span class="line">#import &quot;UserBehaviorMacros.h&quot;</span><br><span class="line">#import &quot;PathMacros.h&quot;</span><br></pre></td></tr></table></figure>
<p>在xcode项目的pch文件中，导入Macros.h文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">XcodeProjectName-Prefix.pch</span><br><span class="line">#ifdef __OBJC__</span><br><span class="line">    #import &lt;UIKit&#x2F;UIKit.h&gt;</span><br><span class="line">    #import &lt;Foundation&#x2F;Foundation.h&gt;</span><br><span class="line">    #import &quot;Macros.h&quot;</span><br><span class="line">#endif</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/iOS/" rel="tag"># iOS</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/d692770.html" rel="prev" title="设计模式">
      <i class="fa fa-chevron-left"></i> 设计模式
    </a></div>
      <div class="post-nav-item">
    <a href="/f91379b.html" rel="next" title="iOS-需要添加的权限配置">
      iOS-需要添加的权限配置 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="YAND"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">YAND</p>
  <div class="site-description" itemprop="description">成长历程 IT笔记 黑苹果 杂谈 建站 服务器 VPS</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">19</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/vvvc" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;vvvc" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:d.zt@qq.com" title="E-Mail → mailto:d.zt@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://vxgo.cn/" title="http:&#x2F;&#x2F;vxgo.cn" rel="noopener" target="_blank">不语玩卡</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="http://www.beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备20023063号 </a>
  </div>

<div class="copyright">
  
  &copy; 2016 – 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">YAND</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
